# -*- coding: utf8 -*-

import os
import sys
reload(sys) 
sys.setdefaultencoding('utf8')
import caller
import webkit
import webpage
import webelement
import time
import caller

gconfig = caller.GlobalConfig()
gconfig.init("127.0.0.1:2181")

#wk = webkit.WebKit("test", True)
wk = webkit.WebKit("test", False)
url = "http://product.suning.com/107919761.html"
page = wk.getWebPage(url, 30000, 40000)

if page is None:
    _exit(0)

print "Get success."
print page.getTitle()

print "Save png."
buf = page.webPageImageBuffer()
fp = open("page.png", "w")
fp.write(buf)
fp.close()

page.destroy(True)
